package com.cloud.util;

/**
 * @author: hxy
 * @date: 2017/10/24 10:16
 */
public class StringUtil {

	public static boolean isNullOrEmpty(String str) {
		return null == str || "".equals(str) || "null".equals(str);
	}

	public static boolean isNullOrEmpty(Object obj) {
		return null == obj || "".equals(obj);
	}

	public static String getAbsoluteFileName(String name) {
		if (name != null) {
			int idx = name.lastIndexOf('.');
			if (idx != -1) {
				return name.substring(0, idx);
			}
		}
		return name;
	}

	public static String getFileNameSuffix(String name) {
		if (name != null) {
			int idx = name.lastIndexOf(".");
			if (idx != -1) {
				return name.substring(idx + 1);
			}
		}
		return null;
	}

	public static void main(String[] args) {
		String name = "test.avi";
		System.out.println(getFileNameSuffix(name));
		System.out.println(getAbsoluteFileName(name));
		System.out.println(System.getProperty("os.name"));
	}
}
